package com.wanxi;

import com.wanxi.SnowflakeIdGenerator;

import java.util.Set;
import java.util.TreeSet;
/**
 * @author 杨金乾
 */
public class SnowMakerTest {
    public static void main(String[] args) {
        SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(1, 2);

        // 生成50个id
        Set<Long> set = new TreeSet<>();
        for (int i = 0; i < 500000; i++) {
            set.add(snowflakeIdGenerator.nextId());
        }
        System.out.println(set);
        System.out.println(set.size());
        // 验证生成100万个id需要多久
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
            snowflakeIdGenerator.nextId();
        }
        System.out.println(System.currentTimeMillis() - startTime);
    }

}
